package com.wanda.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wanda.po.JsonModelGeneral;
import com.wanda.po.Receptiontable;
import com.wanda.po.ReceptiontableExample;
import com.wanda.service.ReceptionService;

@Controller
@RequestMapping("reception")
public class ReceptionController {

	@Autowired
	private ReceptionService receptionService;
	@RequestMapping("/insert")
	public @ResponseBody int insertReception(Receptiontable receptiontable) throws Exception{
		int n = receptionService.insert(receptiontable);
		return n;
	}
	
	@RequestMapping("/List")
	public @ResponseBody JsonModelGeneral selectList(){
		ReceptiontableExample example = new ReceptiontableExample();
		JsonModelGeneral jsonModel = new JsonModelGeneral();
		List<Receptiontable> list = receptionService.selectByExample(example);
		jsonModel.setRows(list);
		return jsonModel;
	}
	
	@RequestMapping("/delete")
	public @ResponseBody int deleteById(Integer id){
		int n = receptionService.deleteByPrimaryKey(id);
		return n;	
	}
	
	@RequestMapping("/select")
	public @ResponseBody JsonModelGeneral selectById(Integer id) throws Exception{
		JsonModelGeneral jsonModel = new JsonModelGeneral();
		Object myobj = receptionService.selectByPrimaryKey(id);
		jsonModel.setMyobj(myobj);
		return jsonModel;
	}
	@RequestMapping("/update")
	public @ResponseBody int updateReception(Receptiontable receptiontable) throws Exception{
		int n = receptionService.updateByPrimaryKey(receptiontable);
		return n;
	}
}
